import csv

def write():
    titles=['name','tall','goal']
    values=[
        ['张三','167','32'],
        ['账务','123','45'],
        ['大大','154','45']
    ]
    with open('collection/tp.csv','w',encoding='utf-8',newline='') as f:
        writer=csv.writer(f)
        writer.writerow(titles)
        writer.writerows(values)

def Dictwrite():
    tiltes=['name','tall','goal']
    values=[
        {'name':'张三','tall':123,'goal':56},
        {'name':'李四','tall':123,'goal':123}
    ]
    with open('collection/tp.csv','w',encoding='utf-8',newline='') as f:
        writer=csv.DictWriter(f,tiltes)
        writer.writeheader()
        writer.writerows(values)

if __name__=='__main__':
    # write()
    Dictwrite()
